package com.rong.DAO;

import com.rong.hibernate.BaseHibernateDAO;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
import com.rong.ORM.ZynPara;

/**
 * A data access object (DAO) providing persistence and search support for
 * ZynPara entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.rong.DAO.ZynPara
 * @author MyEclipse Persistence Tools
 */

public class ZynParaDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(ZynParaDAO.class);
	// property constants
	public static final String ERRO_RATE = "oilprice";
	public static final String DEFAULT_DW = "defaultDw";
	public static final String EXTPARA1 = "extpara1";
	public static final String EXTPARA2 = "extpara2";
	public static final String EXTPARA3 = "extpara3";
	public static final String EXTPARA4 = "extpara4";
	public static final String EXTPARA5 = "extpara5";
	public static final String EXTPARA6 = "extpara6";
	public static final String EXTPARA7 = "extpara7";
	public static final String EXTPARA8 = "extpara8";
	public static final String EXTPARA9 = "extpara9";
	public static final String EXTPARA0 = "extpara0";
	public static final String EXTPARA_DB1 = "extparaDb1";
	public static final String EXTPARA_DB2 = "extparaDb2";
	public static final String EXTPARA_DB3 = "extparaDb3";
	public static final String EXTPARA_DB4 = "extparaDb4";
	public static final String EXTPARA_DB5 = "extparaDb5";
	public static final String EXTPARA_DB6 = "extparaDb6";

	public void save(ZynPara transientInstance) {
		log.debug("saving ZynPara instance");
		try {
			 Transaction ts = null;
             ts = getSession().beginTransaction();
			getSession().save(transientInstance);
			ts.commit();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(ZynPara persistentInstance) {
		log.debug("deleting ZynPara instance");
		try {
			 Transaction ts = null;
             ts = getSession().beginTransaction();
			getSession().delete(persistentInstance);
			ts.commit();
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public ZynPara findById(java.lang.Integer id) {
		log.debug("getting ZynPara instance with id: " + id);
		try {
			ZynPara instance = (ZynPara) getSession().load(ZynPara.class, id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(ZynPara instance) {
		log.debug("finding ZynPara instance by example");
		try {
			List results = getSession().createCriteria("com.rong.DAO.ZynPara")
					.add(Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding ZynPara instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from ZynPara as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByoilprice(Object oilprice) {
		return findByProperty(ERRO_RATE, oilprice);
	}

	public List findByDefaultDw(Object defaultDw) {
		return findByProperty(DEFAULT_DW, defaultDw);
	}

	public List findByExtpara1(Object extpara1) {
		return findByProperty(EXTPARA1, extpara1);
	}

	public List findByExtpara2(Object extpara2) {
		return findByProperty(EXTPARA2, extpara2);
	}

	public List findByExtpara3(Object extpara3) {
		return findByProperty(EXTPARA3, extpara3);
	}

	public List findByExtpara4(Object extpara4) {
		return findByProperty(EXTPARA4, extpara4);
	}

	public List findByExtpara5(Object extpara5) {
		return findByProperty(EXTPARA5, extpara5);
	}

	public List findByExtpara6(Object extpara6) {
		return findByProperty(EXTPARA6, extpara6);
	}

	public List findByExtpara7(Object extpara7) {
		return findByProperty(EXTPARA7, extpara7);
	}

	public List findByExtpara8(Object extpara8) {
		return findByProperty(EXTPARA8, extpara8);
	}

	public List findByExtpara9(Object extpara9) {
		return findByProperty(EXTPARA9, extpara9);
	}

	public List findByExtpara0(Object extpara0) {
		return findByProperty(EXTPARA0, extpara0);
	}

	public List findByExtparaDb1(Object extparaDb1) {
		return findByProperty(EXTPARA_DB1, extparaDb1);
	}

	public List findByExtparaDb2(Object extparaDb2) {
		return findByProperty(EXTPARA_DB2, extparaDb2);
	}

	public List findByExtparaDb3(Object extparaDb3) {
		return findByProperty(EXTPARA_DB3, extparaDb3);
	}

	public List findByExtparaDb4(Object extparaDb4) {
		return findByProperty(EXTPARA_DB4, extparaDb4);
	}

	public List findByExtparaDb5(Object extparaDb5) {
		return findByProperty(EXTPARA_DB5, extparaDb5);
	}

	public List findByExtparaDb6(Object extparaDb6) {
		return findByProperty(EXTPARA_DB6, extparaDb6);
	}

	public List findAll() {
		log.debug("finding all ZynPara instances");
		try {
			String queryString = "from ZynPara";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public ZynPara merge(ZynPara detachedInstance) {
		log.debug("merging ZynPara instance");
		try {
			 Transaction ts = null;
             ts = getSession().beginTransaction();
			ZynPara result = (ZynPara) getSession().merge(detachedInstance);
			ts.commit();
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(ZynPara instance) {
		log.debug("attaching dirty ZynPara instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(ZynPara instance) {
		log.debug("attaching clean ZynPara instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}